home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-14 | 4.3 KB | 170 lines | [TEXT/MPS ] |
- /* _________________________________________________________________________________________________________ //
- Copyright © 1992 Apple Computer, Inc. All rights reserved.
- Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
- Date: 11/22/92
- Programmer: Kent Sandvik
- Revision comments are at the end of this file.
- ---
- TAppleEvent is an Apple Event class that will send and receive Apple Events.
- AppleEvent.cp contains the member functions for the TAppleEvent class.
- _________________________________________________________________________________________________________ */
-
-
- // INCLUDE FILES
- #ifndef _APPLEEVENT_
- #include "AppleEvent.h"
- #endif
-
- // GLOBALS
- const ProcessSerialNumber kSelf = {
- 0, kCurrentProcess};
-
-
- // _________________________________________________________________________________________________________ //
- // TAppleEvent class member function implementations
- // CONSTRUCTORS & DESTRUCTORS
- #pragma segment AppleEvent
- TAppleEvent::TAppleEvent()
- // Create a kCurrentProcess address Apple Event.
- {
- this->Initialize();
- fError = ::AECreateDesc(typeProcessSerialNumber, (Ptr) & kSelf, sizeof(ProcessSerialNumber), &fTarget);
- VASSERT(fError == noErr, ("Problems with AECreateDesc = %d", fError));
- }
-
-
- #pragma segment AppleEvent
- TAppleEvent::TAppleEvent(OSType signature)
- // Create an AE based on the signature type.
- {
- this->Initialize();
- fSignature = signature;
-
- // Create an AEDescriptor from the signature.
- fError = ::AECreateDesc(typeApplSignature, (Ptr) & fSignature, sizeof(fSignature), &fTarget);
- VASSERT(fError == noErr, ("Problems with AECreateDesc = %d", fError));
- }
-
-
- #pragma segment AppleEvent
- TAppleEvent::~TAppleEvent()
- {
- ::AEDisposeDesc(&fAE); // dispose our AE handle
- }
-
-
- #pragma segment AppleEvent
- void TAppleEvent::Initialize()
- // Initialize fields to known values.
- {
- fPriority = kAENormalPriority; // normal level of priority
- fTimeout = kNoTimeOut; // no waiting, just continue
- fSendMode = kAENoReply; // default we are not expecting replies
- fAE.dataHandle = NULL; // clear the message part
- }
-
-
- // MAIN INTERFACES
- #pragma segment AppleEvent
- OSErr TAppleEvent::Define(AEEventClass theClass,
- AEEventID ID)
- // Define the AE based on the AE class and ID.
- {
- fError = ::AECreateAppleEvent(theClass, ID, &fTarget, kAutoGenerateReturnID, kAnyTransactionID, &fAE);
- VASSERT(fError == noErr, ("Problems with AECreateAppleEvent = %d", fError));
-
- return fError;
- }
-
-
- #pragma segment AppleEvent
- OSErr TAppleEvent::Send()
- // Blast off the Apple Event.
- {
- fError = ::AESend(&fAE, &fReply, fSendMode, fPriority, fTimeout, nil, nil);
- VASSERT(fError == noErr, ("Problems with AESend = %d", fError));
-
- return fError;
- }
-
-
- #pragma segment AppleEvent
- OSErr TAppleEvent::Send(AEEventClass theClass,
- AEEventID ID)
- // Blast off the AE with the specs
- {
- this->Define(theClass, ID); // define the AE
- fError = ::AESend(&fAE, &fReply, fSendMode, fPriority, fTimeout, nil, nil);
- VASSERT(fError == noErr, ("Problems with AESend = %d", fError));
-
- return fError;
- }
-
-
- #pragma segment AppleEvent
- void TAppleEvent::SetAddress(const AEAddressDesc address)
- // Set the address of the target AE.
- {
- fError = ::AEPutAttributeDesc(&fAE, keyAddressAttr, &address);
- VASSERT(fError == noErr, ("Problems with AEPutAttributeDesc = %d", fError));
- }
-
-
- // GET/SET MEMBER FUNCTIONS
- #pragma segment AppleEvent
- long TAppleEvent::GetTimeoutValue() const
- // Get current timeout value.
- {
- return fTimeout;
- }
-
-
- #pragma segment AppleEvent
- void TAppleEvent::SetTimeoutValue(const long value)
- // Set new timeout value.
- {
- fTimeout = value;
- }
-
-
- #pragma segment AppleEvent
- AESendMode TAppleEvent::GetSendingMode() const
- // Get AE sending mode.
- {
- return fSendMode;
- }
-
-
- #pragma segment AppleEvent
- void TAppleEvent::SetSendingMode(const AESendMode mode)
- // Set new AE sending mode.
- {
- fSendMode = mode;
- }
-
-
- #pragma segment AppleEvent
- AESendPriority TAppleEvent::GetPriority() const
- // Get current priority level.
- {
- return fPriority;
- }
-
-
- #pragma segment AppleEvent
- void TAppleEvent::SetPriority(const AESendPriority value)
- // Set new priority level.
- {
- fPriority = value;
- }
-
-
- // _________________________________________________________________________________________________________ //
-
- /* Change History (most recent last):
- No Init. Date Comment
- 1 khs 11/22/92 New file
- 2 khs 1/7/93 Cleanup
- */
-
-